﻿using UnityEngine;
using System.Collections;
using UniRx;
using System;

public abstract class MonsterControllerBase : UnitControllerBase
{
    /// <summary>
    /// 怪物AI
    /// </summary>
    public AIBase ai => m_AI ?? CreateAI();
    private AIBase m_AI;
    protected abstract AIBase GetAI();
    private AIBase CreateAI()
    {
        m_AI = GetAI();
        m_AI.Init(entity);
        return m_AI;
    }

    protected override void OnSpawn()
    {
        ai.StartAI();
    }

    protected override void OnDespawn()
    {
        ai.StopAI();
    }

    protected override void OnThaw()
    {
        ai.StartAI();
    }

    protected override void OnFreeze()
    {
        ai.StopAI();
    }
}